package Operations.Calculate;

import Data.DbData;
import GUI.ResultData;
import java.util.ArrayList;

/**
 * @author Martin
 * @version 1.0
 * @created 24-III-2012 8:05:03
 */
public class Max extends ACalculate {

    public Max(ArrayList<DbData> data,ACalculate next,ResultData result){  
        super(data,next,result);
    }
    
    @Override
    public void doOperation(){
        double max = Double.MIN_VALUE;
        
        for(DbData row : dbData)
        {
            if (row.getFlow() > max) max = row.getFlow();
        }
        if(max==Double.MIN_VALUE)
            this.resultData.setMax(0);
        else
            this.resultData.setMax(max);
        super.doOperation();
    }

    @Override
    public void run() {
        doOperation();
    }

}